import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '@/layout'

// 静态路由
const staticRouter = [
	{
		path: '/',
		redirect: { name: 'qykb' },
		component: layout,
		children: [
			// 区域看板
			{
				path: 'qykb',
				name: 'qykb',
				meta: {
					title: 'route.qykb',
					auth: true,
				},
				component: () => import('@/pages/dashboard/qykb'),
			},
			// 业态看板
			{
				path: 'ytkb',
				name: 'ytkb',
				meta: {
					title: 'route.ytkb',
					auth: true,
				},
				component: () => import('@/pages/dashboard/ytkb'),
			},
			// 企业看板
			{
				path: 'qiykb',
				name: 'qiykb',
				meta: {
					title: 'route.qiykb',
					auth: true,
				},
				component: () => import('@/pages/dashboard/qiykb'),
			},
		],
	},
]
// 动态路由
const dynamicRouter = []

// 重新组织后导出
const routes = [...staticRouter, ...dynamicRouter]

Vue.use(VueRouter)

// 创建路由实例化对象
const createRouter = () =>
	new VueRouter({
		mode: 'history', // require service support
		scrollBehavior: () => ({ y: 0 }),
		routes: routes,
	})

const router = createRouter()

export default router
